{
  "properties" : { },
  "id" : "c1ecb2351d4942389651bc14522f5318",
  "script" : null,
  "groupId" : "5b4c0f1fcedc4bfbbf84bb3791e01399",
  "name" : "未绑定告警对象",
  "createTime" : 1727070942021,
  "updateTime" : 1725267536463,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "unBound",
  "method" : "POST",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "{\n    \"targetName\": \"\",\n    \"targetType\": \"\",\n    \"current\": 1,\n    \"size\": 15,\n    \"ruleId\": \"100003\"\n}",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 500,\n    \"message\": \"系统内部出现错误\",\n    \"data\": {}\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : null,
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  },
  "responseBodyDefinition" : {
    "name" : null,
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }
}
================================

sql1 = """
    select * from alarm_target where id not in
    <foreach collection="arrayList" open="(" separator="," close=")" item="item">
        #{item}
    </foreach>
    <if test="body.targetName != null and body.targetName != '' ">
        and target_name like concat('%',#{body.targetName},'%')
    </if>
    <if test="body.targetType != null and body.targetType != '' ">
        and target_type = #{body.targetType}
    </if>
"""

sql2 = """
    select * from alarm_target where target_name is null 
    <if test="body.targetName != null and body.targetName != '' ">
        and target_name = #{body.targetName}
    </if>
"""
    list = db.select(""" select * from alarm_rule_target where rule_id = #{body.ruleId} """)
	arrayList = new ArrayList()
    if (list.size() > 0) {
        for (item in list) {
            arrayList.add(item.targetId);
        }
        return db.page(sql1)
    }
    return db.page(sql2)